package com.example.shop.common.dto;

import com.example.shop.common.api.ResponseResult;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * 前端显示头像
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class Avatar {
    /**
     * 唯一标识
     */
    protected Long id;
    /**
     * 头像
     */
    @Field(type = FieldType.Keyword)
    protected String avatar;

    public void setAvatar(String avatar) {
        this.avatar = ResponseResult.toRequestPath(avatar);
    }

    @Override
    public String toString() {
        return "Avatar{" +
                "id=" + id +
                ", avatar='" + avatar + '\'' +
                '}';
    }
}
